#标准维护任务表，用以存储具体的任务和具体的工作团队
class CreateStandardMaintenances < ActiveRecord::Migration
  def self.up
    create_table :standard_maintenances do |t|
      t.integer   :work_id                                        #工作id
      t.integer   :team_id                                        #团队id
      t.integer   :template_id                                    #模板ID
      t.integer   :begin_minute                                   #开始时间分钟数
      t.integer   :during_minute                                  #持续时间分钟数
      t.string    :description                                    #备注

      t.integer   :is_locked     ,:limit => 1 ,:default => 0      #锁定 1为True 0为False
      t.integer   :lock_version  ,:default => 0                   #乐观锁
      t.timestamps
    end
    StandardMaintenance.create(:work_id => "1" ,:team_id => "1",:template_id => "1",
      :begin_minute => "0" ,:during_minute => "30")
    StandardMaintenance.create(:work_id => "2" ,:team_id => "2",:template_id => "1",
      :begin_minute => "30" ,:during_minute => "30")
    StandardMaintenance.create(:work_id => "3" ,:team_id => "3",:template_id => "1",
      :begin_minute => "35" ,:during_minute => "30")
    StandardMaintenance.create(:work_id => "4" ,:team_id => "4",:template_id => "1",
      :begin_minute => "45" ,:during_minute => "30")
    StandardMaintenance.create(:work_id => "5" ,:team_id => "5",:template_id => "1",
      :begin_minute => "60" ,:during_minute => "30")

    StandardMaintenance.create(:work_id => "1" ,:team_id => "1",:template_id => "2",
      :begin_minute => "0" ,:during_minute => "40")
    StandardMaintenance.create(:work_id => "2" ,:team_id => "2",:template_id => "2",
      :begin_minute => "40" ,:during_minute => "30")
    StandardMaintenance.create(:work_id => "3" ,:team_id => "3",:template_id => "2",
      :begin_minute => "55" ,:during_minute => "30")
    StandardMaintenance.create(:work_id => "4" ,:team_id => "4",:template_id => "2",
      :begin_minute => "110" ,:during_minute => "30")
    StandardMaintenance.create(:work_id => "5" ,:team_id => "5",:template_id => "2",
      :begin_minute => "120" ,:during_minute => "30")
  end

  def self.down
    drop_table :standard_maintenances
  end
end
